home *** CD-ROM | disk | FTP | other *** search
/ Mac Format 1994 October / Macformat17.cdr / Shareware City / Developers / WASTETCL / WASTEEdit ƒ / CEditPane.cp < prev    next >
Text File  |  1994-06-18  |  2KB  |  106 lines

  1. /******************************************************************************
  2.     CEditPane.c
  3.     
  4.     Methods for a text editing pane.
  5.         
  6.     Copyright © 1989 Symantec Corporation. All rights reserved.
  7.  
  8.  ******************************************************************************/
  9.  
  10.  
  11. #include "CEditPane.h"
  12. #include "Commands.h"
  13. #include "CDocument.h"
  14. #include "CBartender.h"
  15. #include "Constants.h"
  16.  
  17. extern    CBartender    *gBartender;
  18.  
  19. void CEditPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
  20.  
  21. {
  22.     Rect    margin;
  23.  
  24.     CWASTEText::IWASTEText(anEnclosure, aSupervisor, 1, 1, 0, 0,
  25.                         sizELASTIC, sizELASTIC, -1); //432);
  26.     FitToEnclosure(TRUE, TRUE);
  27.  
  28.         /**
  29.          **    Give the edit pane a little margin.
  30.          **    Each element of the margin rectangle
  31.          **    specifies by how much to change that
  32.          **    edge. Positive values are down and to
  33.          **    right, negative values are up and to
  34.          **    the left.
  35.          **
  36.          **/
  37.  
  38.     SetRect(&margin, 2, 2, -2, -2);
  39.     ChangeSize(&margin, FALSE);
  40. }
  41.  
  42. void CEditPane::DoCommand(long theCommand)
  43.  
  44. {
  45.     
  46.     if (((theCommand == cmdPaste) || (theCommand == cmdCut)) && 
  47.         !((CDocument *)itsSupervisor)->dirty) {
  48.         
  49.         ((CDocument *)itsSupervisor)->dirty = TRUE;
  50.         gBartender->EnableCmd(cmdSave);
  51.         gBartender->EnableCmd(cmdSaveAs);
  52.     }
  53.  
  54.     inherited::DoCommand(theCommand);
  55. }
  56.  
  57.  
  58. void CEditPane::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
  59.  
  60. {
  61.     
  62.     inherited::DoKeyDown(theChar, keyCode, macEvent);
  63.  
  64.     switch (keyCode) {
  65.     
  66.         case KeyHome:
  67.         case KeyEnd:
  68.         case KeyPageUp:
  69.         case KeyPageDown:
  70.             break;
  71.             
  72.         default:    
  73.             if (!((CDocument *)itsSupervisor)->dirty) {
  74.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  75.                 gBartender->EnableCmd(cmdSave);
  76.                 gBartender->EnableCmd(cmdSaveAs);
  77.             }
  78.             break;
  79.     }
  80. }
  81.  
  82.  
  83. void CEditPane::DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent)
  84.  
  85. {
  86.     
  87.     inherited::DoAutoKey(theChar, keyCode, macEvent);
  88.  
  89.     switch (keyCode) {
  90.     
  91.         case KeyHome:
  92.         case KeyEnd:
  93.         case KeyPageUp:
  94.         case KeyPageDown:
  95.             break;
  96.             
  97.         default:    
  98.             if (!((CDocument *)itsSupervisor)->dirty) {
  99.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  100.                 gBartender->EnableCmd(cmdSave);
  101.                 gBartender->EnableCmd(cmdSaveAs);
  102.             }
  103.             break;
  104.     }
  105. }
  106.